#include <iostream>
#include <string>
#include <fcntl.h>
#include <cstring>
#include <cerrno>
#include "comm.h"
#include <stdio.h>
#include <unistd.h>
int main()
{
    int wfd = open(FILENAME, O_WRONLY);
    if (wfd < 0)
    {
        std::cout << "open  fail!  errno:" << errno << ":" << strerror(errno) << std::endl;
        return -1;
    }
    // 可以开始通信了
    std::string message;
    while (true)
    {
        std::cout << "Please Enter#";
        getline(std::cin, message);

        ssize_t ret = write(wfd, message.c_str(), message.size());
        if (ret < 0)
        {
            std::cout << "write  fail!  errno:" << errno << ":" << strerror(errno) << std::endl;
            break;
        }
    }
    close(wfd);
    return 0;
}